#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
string Inf, Ansf, Outf;
int n, tp, p[N], c[N], p1[N];
int pp[N], cc[N];
void perform(string Name, vector<pair<int, int> > moves) {
	memcpy(pp, p, sizeof (p));
	memcpy(cc, c, sizeof (c));
	for (int i = 0; i < moves.size(); ++i) {
		int x = moves[i].first, y = moves[i].second;
		if (cc[pp[x]] == cc[pp[y]]) {
			printf("Wrong Answer: Sorry, performance is invalid: ");
			cout << Name << '\n';
			assert(0);
		} else swap(pp[x], pp[y]);
	}
	for (int i = 1; i <= n; ++i) if (pp[i] != i) {
		printf("Wrong Answer: Sorry, performance is invalid: ");
		cout << Name << '\n';
		assert(0);
	}
}
int main() {
	cin >> Inf >> Ansf >> Outf;
	FILE* In = fopen(Inf.c_str(), "r");
	FILE* Ans = fopen(Ansf.c_str(), "r");
	FILE* Out = fopen(Outf.c_str(), "r");
	fscanf(In, "%d%d", &n, &tp);
	if (n < 1 || n > 100000) {
		puts("Invalid Input: N is invalid");
		assert(0);
	}
	for (int i = 1; i <= n; ++i) fscanf(In, "%d", &p[i]), p1[i] = p[i];
	sort (p1 + 1, p1 + 1 + n);
	for (int i = 1; i <= n; ++i) if (p1[i] != i) {
		puts("Invalid Input: Sequence P is not a permutation");
		assert(0);
	}
	for (int i = 1; i <= n; ++i) {
		fscanf(In, "%d", &c[p[i]]);
		if (c[p[i]] < 1 || c[p[i]] > n) {
			puts("Invalid Input: Sequence C is invalid");
			assert(0);
		}
	}
	vector<pair<int, int> > J, P;
	int siz = 0;
	fscanf(Ans, "%d", &siz);
	for (int i = 0; i < siz; ++i) {
		int x, y;
		fscanf(Ans, "%d%d", &x, &y);
		J.push_back(make_pair(x, y));
	}
	int siz1 = 0;
	cerr << "here " << siz1 << '\n';
	fscanf(Out, "%d", &siz1);
	if (siz == -1) {
		if (siz1 != -1) {
			puts("Wrong Answer: Sorry, Your answer is not correct");
			assert(0);
		}
		else puts("Accepted: Your answer is correct");
		return 0;
	}
	if (tp == 1) {
		if (siz1 > 5000000) {
			puts("Sorry, checker will TLE");
			assert(0);
		}
	} else if (tp == 0) {
		if (siz1 != siz) {
			puts("Wrong Answer: Sorry, Your answer is not correct");
			assert(0);
		}
	} else {
			puts("Invalid Input: Type is invalid");
			assert(0);
	}
	for (int i = 0; i < siz1; ++i) {
		int x, y;
		fscanf(Out, "%d%d", &x, &y);
		P.push_back(make_pair(x, y));
	}
	perform(Ansf, J);
	perform(Outf, P);
	puts("Accepted: Your answer is correct");
	return 0;
}
